﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using RoketPack.Management;

namespace RoketPack.RepositoryUI
{
    public partial class InstallPage : Wizard.UI.InternalWizardPage
    {
        private RepositoryInstallationWizard m_Wizard = null;

        public InstallPage(RepositoryInstallationWizard wizard)
        {
            InitializeComponent();

            this.m_Wizard = wizard;
        }

        private void InstallPage_SetActive(object sender, CancelEventArgs e)
        {
            this.SetWizardButtons(Wizard.UI.WizardButtons.Finish);
            this.GetWizard().CancelEnabled = false;

            this.c_InstallRepositoryManager.Repositories.Add(
                new Repository(this.m_Wizard.RepositoryUrl, this.m_Wizard.RepositoryName, this.m_Wizard.RepositoryDescription)
                );
            this.c_InstallRepositoryManager.SelectedIndex = 0;
        }

        private void InstallPage_WizardFinish(object sender, CancelEventArgs e)
        {
            if (this.c_InstallRepositoryCheckBox.Checked)
            {
                this.m_Wizard.InstallRepository(
                    new Repository(this.m_Wizard.RepositoryUrl, this.m_Wizard.RepositoryName, this.m_Wizard.RepositoryDescription)
                    );
            }
        }
    }
}
